﻿using System;
using System.Collections.Generic;
using System.Text;


// 哈夫曼树结点
public class HuffmanTreeNode
{
    public int value;//节点权值
    public HuffmanTreeNode left;//左子节点
    public HuffmanTreeNode right;//右子节点

    public HuffmanTreeNode(int value)
    {
        this.value = value;
    }

    public int CompareTo(object obj)
    {
        //从小到大排序
        HuffmanTreeNode p = obj as HuffmanTreeNode;
        return this.value.CompareTo(p.value);
    }

    public override string ToString()
    {
        return "Node[value=" + value + "]";
    }

    // 前序遍历
    public void PreOrder()
    {
        Console.WriteLine(this);
        if (this.left != null)
        {
            this.left.PreOrder();
        }
        if (this.right != null)
        {
            this.right.PreOrder();
        }
    }
}
